<script type="text/javascript">

function change_style(path){
	document.getElementById('css1').href = '<?php echo base_url();?>application/views/css/'+path;

	$.ajax({
        url: "<?php echo site_url('account/save_user_style');?>",
		   type: 'POST',
		   data: {style: path},
	});
}

function change_bg(which){
	switch_bg(which);

	$.ajax({
        url: "<?php echo site_url('account/save_user_bg');?>",
		   type: 'POST',
		   data: {background: which},
	});
}

$(document).ready(function () {
	//$('#username').select();
	$('input[type="radio"]').change( function() {
		alert("lol");
	});

	$('#bg0').click(function(){
		alert("power");
	});
	
	$('#submit_account').click(function(){
		//$("#submit_display").empty();
		//$("#submit_display").append("<img id='theImg' src='<?php echo base_url();?>application/views/images/ajax-loader.gif'/>");
		
		var form_data = {
			name: $('#username').val(),
			pass: $('#password').val(),
			pass2: $('#password2').val(),
			email: $('#email').val()
		};
		
		$.ajax({
           url: "<?php echo site_url('account/check_account_form');?>",
		   type: 'POST',
           data: form_data,
           
           success: function (msg) {
				var _text = "error";
				var _color = "red";
				if(msg!="okokok"){
					_text = "Invalid form data";
					_color = "orange";
				}else{
					_text = "Account created";
					_color = "green";

					//switch to the new page
					var _window = $('#submit_account').closest("div");
					close_window(_window);
					var my_window = add_window(300,110,"Account Created!");
					//$(my_window).append(msg);
					//$(_window).delay(500).fadeIn(500);
					$(my_window).append($("<div>").load("<?php echo base_url();?>application/views/insert_account.php"));
					$(my_window).append(form_data['name']);

					
					
					//$(_window).load("<?php echo base_url();?>application/views/insert_account.php",{},function(){
					//	$(this).append(form_data['name']);
		            //});
				}
				$("#submit_display").empty();
				$("#submit_display").append("<div style='color: "+_color+";'>"+_text+"</div>");
				
				
           }
         });
		 
		return false;
	});

});

</script>